package ca.concordia.soen6461.wichf.navigation.action;

import java.util.Date;

import ca.concordia.soen6461.wichf.entity.ScheduledEvent.Type;
import ca.concordia.soen6461.wichf.entity.User;
import ca.concordia.soen6461.wichf.navigation.event.ManageAppointmentEvent;
import ca.concordia.soen6461.wichf.navigation.view.DoctorHomeView;
import ca.concordia.soen6461.wichf.navigation.view.HomeView;
import ca.concordia.soen6461.wichf.service.SchedulingService;

public class DoMakeAvailabilityTo extends DoManageAppointment {

	private boolean available;
	
	public DoMakeAvailabilityTo(SchedulingService schedulingService, boolean available) {
		super(schedulingService);
		this.available = available;
	}
	
	protected void manageAppointment(SchedulingService schedulingService, ManageAppointmentEvent event, User user, Date date) {
		DoctorHomeView.AvailabilityLimit fromLimit = event.getSession().drop(DoctorHomeView.AvailabilityLimit.class);
		Date from = HomeView.getDate(fromLimit.getDay(), fromLimit.getSlot()).getTime();
		Date to = HomeView.getDate(event.getDay(), event.getTime() + 1).getTime();
		schedulingService.changeAvailability(user, from, to, available);
	}
	
	@Override
	protected Type getEventType() {
		return null;
	}

}
